import traversal.PreOrderTraversal;

public class MaxDepth {
    private static class TreeNode{
        int val;
        TreeNode left;
        TreeNode right;
        public TreeNode(int val)
        {
            this.val = val;
        }
    }
    class Solution {
        public int maxDepth(TreeNode root) {
            return getDepth(root);

        }

        private int getDepth(TreeNode node)
        {
            if(node == null) return 0;
            int ld = getDepth(node.left);
            int rd = getDepth(node.right);
            return 1 + Math.max(ld,rd);
        }
    }
}
